
from apps.common.base.serializers import *
from apps.system.lessee.models import *

class LesseeBaseSerializer(BaseSerializer):

    class Meta:
        model = Lessee
        fields = "__all__"

class LesseeModelSerializer(LesseeBaseSerializer):

    adminModel = serializers.SerializerMethodField()

    def get_adminModel(self, obj):
        try:
            return {'id': obj.user.id, 'username': obj.user.username, 'nickname': obj.user.nickname, 'phone': obj.user.phone, 'code': obj.user.code}
        except:
            return {}

    class Meta:
        model = Lessee
        fields = "__all__"